{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cb33733e-6f7f-4ab9-a140-5d7fdbefcbfc",
   "metadata": {},
   "source": [
    "# Horizontal Error Bars\n",
    "\n",
    "This example overlays a scatter plot of the mean bill length of a set of penguins per island with error bars computed from their standard deviation."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b902437-2407-4db2-81b5-19f8761791b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "df = hvplot.sampledata.penguins(\"pandas\")\n",
    "df = df.groupby(\"island\").agg({\"bill_length_mm\": [\"mean\", \"std\"]})\n",
    "df.columns = df.columns.droplevel(0)\n",
    "\n",
    "scatter = df.hvplot.scatter(y=\"mean\")\n",
    "errorbars = df.hvplot.errorbars(\n",
    "    y=\"mean\",\n",
    "    yerr1=\"std\",\n",
    "    invert=True,\n",
    "    ylabel=\"Bill Length (mm)\",\n",
    "    title=\"Horizontal Error Bars (Bokeh)\",\n",
    ")\n",
    "scatter * errorbars"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a6f655a2-9c63-43d9-a1a5-2d7bc037c85d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "hvplot.extension(\"matplotlib\")\n",
    "\n",
    "df = hvplot.sampledata.penguins(\"pandas\")\n",
    "df = df.groupby(\"island\").agg({\"bill_length_mm\": [\"mean\", \"std\"]})\n",
    "df.columns = df.columns.droplevel(0)\n",
    "\n",
    "scatter = df.hvplot.scatter(y=\"mean\")\n",
    "errorbars = df.hvplot.errorbars(\n",
    "    y=\"mean\",\n",
    "    yerr1=\"std\",\n",
    "    invert=True,\n",
    "    ylabel=\"Bill Length (mm)\",\n",
    "    title=\"Horizontal Error Bars (Matplotlib)\",\n",
    ")\n",
    "scatter * errorbars"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "53acc1eb-f6ef-4b5a-a674-fff34b91bf1e",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Scatter Plot reference documentation](../../ref/api/manual/hvplot.hvPlot.scatter.ipynb).\n",
    "- [Error Bars Plot reference documentation](../../ref/api/manual/hvplot.hvPlot.errorbars.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
